package com.shop2cn.app.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.app.liveseller.parameter.*;
import com.shop2cn.app.liveseller.service.*;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.LiveRoomShop2cnCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.livesellerShop2cn.*;
import com.ymttest.database.sqlwapper.livesellerShop2cn.LiveRoomShop2cnWapper;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
/**
*买手（主播）删除直播
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_RemoveSellerLive{
	private static RemoveSellerLiveBean removesellerliveBean;
	private static RemoveSellerLiveCall removesellerliveCall;
	private static LiveRoomShop2cnWapper LiveRoomShop2cnWapper;
	private static int sellerId ;
	private static String token ;
	private static int csId;
	private static String cstoken;
	
	@BeforeClass
	public static void setUp() throws Exception {
		Logger.createResultFile("买手（主播）删除直播");
		sellerId = GodmchManageCallService.CreateSellerMch();
		token=AuthCallServiceV2.createToken(sellerId, "app");
		csId = GodmchManageCallService.bindClientService(
				sellerId, 1);
		cstoken = AuthCallServiceV2.createToken(csId, "app");
	}

	@Before
	public void caseUp() {
		removesellerliveBean=new RemoveSellerLiveBean();
		removesellerliveCall=new RemoveSellerLiveCall();
		LiveRoomShop2cnWapper=new LiveRoomShop2cnWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(removesellerliveCall.getOpurl());
		LiveRoomShop2cnWapper=null;
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_RemoveSellerLive_001() {
		Logger.start(true,"status7买手（主播）删除直播成功");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("{}", removesellerliveCall.getReturnData(), "验证Code");
			
			LiveRoom dblive = LiveRoomShop2cnWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_RemoveSellerLive_002() {
		Logger.start(true,"不输入liveid失败");
		try {
//			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
//			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
//			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("400", removesellerliveCall.getString("code"), "验证Code");
			Logger.verifyEquals("直播Id参数错误", removesellerliveCall.getString("msg"), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_RemoveSellerLive_003() {
		Logger.start(true,"不输入token失败");
		try {
			removesellerliveBean.setLiveId(1);
			removesellerliveCall.setData(removesellerliveBean);
			removesellerliveCall.callService();			
			Logger.verifyEquals("400", removesellerliveCall.getString("code"), "验证Code");
//			Logger.verifyEquals("买手Id参数错误", removesellerliveCall.getString("msg"), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_004() {
		Logger.start(true,"liveid和userid不匹配失败");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 9);
			removesellerliveBean.setLiveId(createlive.getId());
			removesellerliveCall.setData(removesellerliveBean);
			int sellerId1= GodmchManageCallService.CreateSellerMch();
			String token1=AuthCallServiceV2.createToken(sellerId1, "app");
			String head="accesstoken="+token1;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
//			Logger.verifyEquals("400", removesellerliveCall.getString("code"), "验证Code");
			LiveRoom dblive = LiveRoomShop2cnWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(0, dblive.getAction(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_005() {
		Logger.start(true,"status8已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnCallService.CloseSellerLive(createlive.getId(), createlive.getUserId(), 8);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("{}", removesellerliveCall.getReturnData(), "验证Code");
			
			LiveRoom dblive = LiveRoomShop2cnWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_006() {
		Logger.start(true,"status9已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 9);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("{}", removesellerliveCall.getReturnData(), "验证Code");
			
			LiveRoom dblive = LiveRoomShop2cnWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_007() {
		Logger.start(true,"status10已关闭直播运营端删除成功");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 10);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("{}", removesellerliveCall.getReturnData(), "验证Code");
			
			LiveRoom dblive = LiveRoomShop2cnWapper.selectLiveRoomById(createlive.getId());
			Logger.verifyEquals(-1, dblive.getAction(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_008() {
		Logger.start(true,"status0直播未开始删除失败");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_009() {
		Logger.start(true,"status2直播推流删除失败");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnCallService.SellerLiveOnline(createlive.getId(),createlive.getUserId());
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_RemoveSellerLive_010() {
		Logger.start(true,"status3直播断流删除失败");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnCallService.SellerLiveOnline(createlive.getId(),createlive.getUserId());
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 3);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+token;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("201", removesellerliveCall.getString("code"), "验证Code");
			Logger.verifyIsContains("无法删除", removesellerliveCall.getString("msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_RemoveSellerLive_011() {
		Logger.start(true,"客服删除直播成功");
		try {
			LiveRoom createlive = LiveRoomShop2cnCallService.CreateSellerLive(LiveRoomShop2cnCallService.initCreatesellerliveBean(),sellerId);
			LiveRoomShop2cnWapper.updateLiveRoomPushStatus(createlive.getId(), 7);
			removesellerliveBean.setLiveId(createlive.getId());
			
			removesellerliveCall.setData(removesellerliveBean);
			String head="accesstoken="+cstoken;
			removesellerliveCall.addHeader("ymt-pars", head);
			removesellerliveCall.callService();			
			Logger.verifyEquals("400", removesellerliveCall.getString("code"), "验证Code");
			Logger.verifyIsContains("不能删除", removesellerliveCall.getString("msg"), "验证Msg");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}